package io.github.talelin.latticy.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.talelin.latticy.dto.warehouse.UpdateWareDTO;
import io.github.talelin.latticy.dto.warehouse.WarehouseDTO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

/**
 * 仓库
 *
 * @author generator@wulongbo
 * @since 2022-05-10
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode()
@Accessors(chain = true)
@TableName("warehouse")
public class WarehouseDO implements Serializable {

    private static final long serialVersionUID = 6503833204618152910L;
    /**
     * warehouseCode
     */
    @TableId(value = "code", type = IdType.INPUT)
    private String code;

    /**
     * 仓库名称
     */
    private String name;

    /**
     * 仓库面积
     */
    private BigDecimal size;

    /**
     * warehouse 所属国家
     */
    private String country;

    /**
     * 州/省
     */
    private String province;

    /**
     * 市 /区县
     */
    private String city;

    /**
     * 街道地址
     */
    private String street;

    /**
     * 单位/公寓/套房编号
     */
    private String apartment;

    /**
     * 时区编码
     */
    private String timeZone;

    /**
     * 邮编
     */
    private String postcode;

    /**
     * 仓库描述
     */
    private String description;

    /**
     * 类型：0:标准;1:中转
     */
    private Boolean type;

    /**
     * 0:不可用;1:可用
     */
    private Boolean status;

    /**
     * 联系人
     */
    private String contactor;

    /**
     * 公司
     */
    private String company;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    @JsonIgnore
    private Date createTime;

    @JsonIgnore
    private Date updateTime;

    @TableLogic
    @JsonIgnore
    private Date deleteTime;

    public WarehouseDO(WarehouseDTO dto) {
        BeanUtils.copyProperties(dto, this);
    }

    public WarehouseDO(String code, UpdateWareDTO dto) {
        BeanUtils.copyProperties(dto, this);
        this.setCode(code);
    }
}
